<?php

/*
|--------------------------------------------------------------------------
| Admin Routes
|--------------------------------------------------------------------------
|
| 后台管理操作
|
*/

Route::group(['namespace' => 'Admin','prefix'=>'admin'], function () {
    Route::get('/login','LoginController@index');
    Route::post('/login','LoginController@login');
    Route::get('/logout','LoginController@logout');

    Route::group(['middleware' =>'auth_admin:admin'], function () {
        Route::get('/index','HomeController@index');

        Route::group(['middleware' => ['can:system']],function (){
            //用户管理
            Route::get('/users','UsersController@index');
            Route::get('/users/create','UsersController@create');
            Route::post('/users/store','UsersController@store');
            Route::get('/users/{user}/role', 'UsersController@role');
            Route::post('/users/{user}/role', 'UsersController@storeRole');

            // 角色管理
            Route::get('/roles', 'RoleController@index');
            Route::get('/roles/create', 'RoleController@create');
            Route::post('/roles/store', 'RoleController@store');
            Route::get('/roles/{role}/permission', 'RoleController@permission');
            Route::post('/roles/{role}/permission', 'RoleController@storePermission');

            // 权限管理
            Route::get('/permissions', 'PermissionController@index');
            Route::get('/permissions/create', 'PermissionController@create');
            Route::post('/permissions/store', 'PermissionController@store');
        });

        //文章
        Route::group(['middleware' =>['can:post']],function (){
            Route::get('/post','PostsController@index');
            Route::get('/post/create','PostsController@create');
            Route::post('/post/store','PostsController@store');
            Route::get('/post/{id}/edit','PostsController@edit');
            Route::post('/post/{id}/update','PostsController@update');
            Route::post('/post/image/upload','PostsController@imageUpload');

        });
        //分类
            Route::get('/type','TypesController@index');
            Route::get('/type/create','TypesController@create');
            Route::post('/type/store','TypesController@store');
            Route::get('/type/{id}/edit','TypesController@edit');
            Route::post('/type/{id}/update','TypesController@update');

        //标签
            Route::get('/tag','TagsController@index');
    });
});

